#pragma once
#include <unistd.h>

#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>

#include "Log.hpp"

using std::cout;
using std::endl;

#define MAX_BUF_SIZE 1024
#define PASSWORD_MIN 1

const char* svr_ip = "192.168.67.131";
const uint16_t svr_port = 23333;
const socklen_t sizeof_sockaddr_in = sizeof(sockaddr_in);

enum UserRequire{
  LOGINON = 1,
  REGISTER,
  CHAT,
  LOGOUT
};

class SmartLock{
  public:
    SmartLock(pthread_mutex_t* src)
    :p_lock(src){}

    void Lock(){
      pthread_mutex_lock(p_lock);
    }

    ~SmartLock(){
      pthread_mutex_unlock(p_lock);
    }
  private:
    SmartLock(const SmartLock&) = delete;
    SmartLock& operator=(const SmartLock&) = delete;

    pthread_mutex_t* p_lock;
};
